package com.cn.lyl.dao.impl;

import com.cn.lyl.dao.NavDao;
import com.cn.lyl.model.NavModel;
import com.cn.lyl.util.JDBC;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class NavDaoImpl implements NavDao {

    @Override
    public List<NavModel> findNavList()
    {
        List<NavModel> navModels = new ArrayList<NavModel>();
        String sql = "select * from nav";
        ResultSet query = JDBC.query(sql);
        try {
            while(query.next()){
                NavModel navModel = new NavModel();
                navModel.setTitle(query.getString("title"));
                navModel.setHref(query.getString("href"));
                navModels.add(navModel);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return navModels;
    }

}
